package com.ctg.behavior.utils;

import lombok.Data;

/**
 * @author zhubocheng
 */
@Data
public class ReturnUtil {

    public static final String SUCCESSFUL_CODE = "0";
    public static final String FAILED_CODE = "-1";
    public static final String SUCCESSFUL_MESG = "处理成功";
    public static final String FAILED_MESG = "处理失败";

    //返回结果码
    private String code;
    //返回结果描述
    private String message;
    //返回数据
    private Object data;

    public ReturnUtil(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public ReturnUtil(String code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ReturnUtil() {
    }

    public static ReturnUtil error(String message) {
        return new ReturnUtil(FAILED_CODE,message);
    }

    public static ReturnUtil error(String message,Object data) {
        return new ReturnUtil(FAILED_CODE,message,data);
    }

    public static ReturnUtil success() {
        return new ReturnUtil(SUCCESSFUL_CODE,SUCCESSFUL_MESG);
    }

    public static ReturnUtil success(Object data) {
        return new ReturnUtil(SUCCESSFUL_CODE,SUCCESSFUL_MESG,data);
    }

    public static ReturnUtil success(String message ,Object data) {
        return new ReturnUtil(SUCCESSFUL_CODE,message,data);
    }
}
